package com.longge;

import java.util.Arrays;

/**
 * @program: my-code
 * @description:
 * @author: longge
 * @create: 2021-06-01 01:07
 */
public class FindContentChildren {

    public int findContentChildren(int[] g, int[] s) {

        Arrays.sort(g);
        Arrays.sort(s);
        int j = s.length - 1, i;
        for (i = g.length - 1; i >= 0; i--) {
            if (j < 0) return s.length;
            if (s[j] >= g[i]) j--;
        }
        return s.length - j - 1;
    }
}
